class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        res = []
        map = {}
        for str in strs:
            l = list(str)
            l.sort()
            s1 = "".join(l)
            if map.has_key(s1):
                l1 = map[s1]
                l1.append(str)
            else:
                new = [str]
                map[s1] = new
                res.append(new)
        return res




test = Solution()
test.groupAnagrams(["eat","tea","tan","ate","nat","bat"])